package com.heima.admin.controller.v1;

import com.heima.admin.service.AuthService;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.model.user.dtos.AuthDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author xjs
 * @date 2022/9/5 17:49
 * description
 */
@RestController
@RequestMapping("/api/v1/auth")
public class AuthController {

    @Autowired
    private AuthService authService;

    @PostMapping("/list")
    public ResponseResult authList(@RequestBody AuthDto authDto){
        return authService.list(authDto);
    };

    @PostMapping("/authPass")
    public ResponseResult authPass(@RequestBody AuthDto authDto){
        authDto.setStatus(9);
        authService.authPass(authDto);
        return ResponseResult.okResult(AppHttpCodeEnum.SUCCESS);
    };

    @PostMapping("/authFail")
    public ResponseResult authFail(@RequestBody AuthDto authDto){
        authDto.setStatus(2);
        authService.authPass(authDto);
        return ResponseResult.okResult(AppHttpCodeEnum.SUCCESS);
    };
}
